package com.wenlin.userservice.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;


/***
 *  Created with IntelliJ IDEA.
 *  Author:  wenlin
 *  Date:  2018/3/26 16:00
 *  Description:
 **/

@Configuration
@PropertySource(value = "classpath:/application.properties")
public class RedissonConfig {

    @Value("${redisson.url}")
    private String url;

    private Integer database = 5;

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer().setAddress(url);
        config.useSingleServer().setDatabase(database);
        return Redisson.create(config);
    }

}
